#ifndef _GLWIDGET_H
#define _GLWIDGET_H

#include <QtOpenGL/QGLWidget>
#include <string>
#include "../geometry/polygon.h"
#include "../geometry/grid.h"

#include "generatepoints.h"
#include "typedefs.h"

class TestDrawer : public QGLWidget
{
    Q_OBJECT

public:
    TestDrawer(QWidget * parent = NULL);
    void save(std::string const & file) const;

protected:
    void createPolygon();
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void keyPressEvent(QKeyEvent *event);

private:
    polygon_t polygon_;
    grid_t grid_;
    Points points_;

    std::vector<bool> points_states_;
    std::vector<bool> points_states_grid_;
    double scale_;
    double h_position_;
    double v_position_;
    int map_file_num_;
    void paintPolygon();
    void paintPoints();
    void paintGrid();
    //void gridScale();
    point_t scalePoint(point_t point) const;
    void updateGrid(double cell_size);
};

#endif
